<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        li {
            width: 500px;
            height: 50px;
            background-color: rgb(136, 138, 58);
            margin-top: 10px;
        }
    </style>
</head>

<body>
    <button>添加一个li</button>
    <ul>
        <li>啊啊啊</li>
    </ul>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <script>

        $(function () {
            var arr = [1, 2, 3, 4];
            function renderLi() {
                var str = "";
                for (var i = 0; i < arr.length; i++) {
                    str += "<li>" + arr[i] + "</li>";
                }
                $("ul").html(str);
            }
            renderLi();
           
            $("button").click(function () {
                arr.push(arr.length + 1);
                renderLi();
            })
        })
    </script>
</body>

</html>